<cfparam name="Fund_Survey_ID" type="integer" default="0" />
<cfparam name="Organization_ID" type="integer" default="0" />
<cfparam name="returnView" type="string" default="funds" />
<cfparam name="passback" type="string" default="" />

<cfscript>
	fundSurveyGateway = new assets.calgrants.com.gateway.FundSurvey2015Gateway();
	fundSurvey = fundSurveyGateway.get(Fund_Survey_ID = Fund_Survey_ID);
	fundSurvey.setProgram_Year("2014-2015");
	if (fundSurvey.getFund_Survey_ID() eq 0 AND request.authUser.organizationID gt 0) {
		fundSurvey.setOrganization_ID(request.authUser.organizationID);
	} else if (Organization_ID gt 0) {
		fundSurvey.setOrganization_ID(Organization_ID);
	}
	if (fundSurvey.getFund_Survey_ID() eq 0) {
		fundSurvey.setSubmitted_By_ID(GetAuthUser());
	}
</cfscript>

<cfif fundSurvey.getOrganization_ID() eq 0>

	<cfset returnView = "editFundSurvey" />
	<cfset cancelView = "funds" />
	<cfset passback = "Fund_Survey_ID,0" />
	<cfinclude template="/assets/calgrants/ui/forms/selectOrganization.cfm">

<cfelseif fundSurvey.getOrganization_ID() gt 0 and IsNumeric(fundSurvey.getFund_Survey_ID())>

	<cfscript>
		base = new assets.calgrants.com.Base();
		passbackQueryString = base.passbackToQueryString(passback);
		organizationGateway = new assets.calgrants.com.gateway.OrganizationGateway();
		organization = organizationGateway.get(Organization_ID = fundSurvey.getOrganization_ID());
		userGateway = new assets.calgrants.com.gateway.UserGateway();
		submittedBy = userGateway.get(User_ID = fundSurvey.getSubmitted_By_ID());
		//qFundSurvey = fundSurveyGateway.query(Fund_ID = fund.getFund_ID());
		//fundSurvey = fundSurveyGateway.get(Fund_Survey_ID = IIf(fund.getFund_ID() gt 0, qFundSurvey.Fund_Survey_ID, 0));
	</cfscript>
	<script type="text/javascript" language="javascript">
	<!--
		<cfoutput>
			var fundSurveyID = #fundSurvey.getFund_Survey_ID()#;
		</cfoutput>
		
		validate = function() {
			var errors = "";
			var valid = true;
			return valid;
		}
		$(function() {
			$("#fundSurveyModal").modal();
			resizeModal("fundSurveyModal");
		})
	//-->
	</script>
	<style type="text/css">
		.slim-col {
			width: 70px;
		}
		.grid-table {
			width: 1010px;
		}
		.q {
			padding-bottom: 10px;
		}
		.text-well {
			width: 780px;
		}
		.ta {
			width: 780px;
			height: 100px;
		}
	</style>
	<cfoutput>
		<cfform id="fundSurveyForm" name="fundSurveyForm" action="#script_name#" method="post" onsubmit="return validate();">
			<cfinput type="hidden" name="action" value="saveFundSurvey" />
			<cfinput type="hidden" name="view" value="#returnView#" />
			<cfinput type="hidden" name="Fund_Survey_ID" value="#fundSurvey.getFund_Survey_ID()#" />
			<cfinput type="hidden" name="Organization_ID" value="#fundSurvey.getOrganization_ID()#" />
			<cfinput type="hidden" name="Submitted_By_ID" value="#fundSurvey.getSubmitted_By_ID()#" />
			<cfinput type="hidden" name="Program_Year" value="#fundSurvey.getProgram_Year()#" />
			<cfif IsDefined("passback")>
				<cfloop index="keyValue" list="#passback#" delimiters=";">
					<cfinput type="hidden" name="#ListFirst(keyValue)#" value="#ListLast(keyValue)#" />
				</cfloop>
			</cfif>
			<div id="fundSurveyModal" class="modal modal-fullscreen" data-backdrop="static">
				<div class="modal-header">
					<h3>Organizer Exit Survey</h3>
				</div>
				<div class="modal-body">
					<div class="container-fluid">
						<div class="row-fluid">
							<div class="span12">
								<p>Thank you for taking the time to complete an Organizer Exit Survey.  Your feedback is valuable in helping us evaluate the Cash for College program and improve our service to you and the students we serve.</p>
								<cfif fundSurvey.getFund_Survey_ID() eq 0>
									<cfinclude template="/assets/calgrants/ui/forms/fundSurvey#ListLast(fundSurvey.getProgram_Year(), '-')#.cfm">
								<cfelse>
									<cfinclude template="/assets/calgrants/ui/details/fundSurvey#ListLast(fundSurvey.getProgram_Year(), '-')#.cfm">
								</cfif>					
							</div>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<a href="?view=#returnView#&#passbackQueryString#" class="btn btn-success">Cancel</a>
					<button type="submit" name="saveButton" class="btn btn-success">Save</button>
				</div>
			</div>
		</cfform>
	</cfoutput>
<cfelse>
	<div class="alert alert-info notFound">Organizer Exit Survey not found</div>
</cfif>